package edu.towson.cosc603.coffeemaker;

import static org.junit.Assert.*;
import junit.framework.TestCase;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class CoffeeMakerTest extends TestCase{
	CoffeeMaker cm;
	Inventory i;
	Recipe r1,r2,r3,r4,r5;
	
	@Before
	public void setUp() throws Exception {
		cm = new CoffeeMaker();
		i = new Inventory();
		
		r2 = new Recipe();

		r1 = new Recipe ();
		r1.setAmtChocolate(9);
		r1.setAmtCoffee(8);
		r1.setAmtMilk(7);
		r1.setAmtSugar(7);
		r1.setName("Nervana");
		r1.setPrice(3);
		
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testCoffeeMaker() {
	}

	@Test
	public void testAddRecipe() {
		cm.addRecipe(r1);
		Assert.assertTrue(true);
	}

	@Test
	public void testAddRecipeExists() {
		cm.addRecipe(r1);
		cm.addRecipe(r1);
		Assert.assertFalse(false);
	}
	

	@Test
	public void testEditRecipe() {
		cm.addRecipe(r1);
		r2 = r1;
		r2.setAmtCoffee(4);
		Assert.assertTrue(cm.editRecipe(r1, r2));
	}
	
	@Test
	public void testEditRecipeCanNot() {
		cm.addRecipe(r1);
		cm.editRecipe(r2, r1 );
		Assert.assertFalse(false);
	}
	
	@Test
	public void testDeleteRecipe(){
		cm.addRecipe(r1);
		Assert.assertTrue(cm.deleteRecipe(r1));
	}
	
	@Test
	public void testAddInventory() {
		int amtCoffee = 3;
		int amtMilk = 2;
		int amtSugar = 0;
		int amtChocolate = 2;
		Assert.assertTrue(cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate));
	}

	@Test
	public void testAddInventoryLessThanZeroCoffee() {
		int amtCoffee = -3;
		int amtMilk = 2;
		int amtSugar = 0;
		int amtChocolate = 2;
		Assert.assertFalse(cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate));
	}
	
	@Test
	public void testAddInventoryLessThanZeroMilk() {
		int amtCoffee = 3;
		int amtMilk = -2;
		int amtSugar = 0;
		int amtChocolate = 2;
		Assert.assertFalse(cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate));
	}
	
	@Test
	public void testAddInventoryLessThanZeroChocolate() {
		int amtCoffee = 3;
		int amtMilk = 2;
		int amtSugar = 0;
		int amtChocolate = -2;
		Assert.assertFalse(cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate));
	}
	
	
	@Test
	public void testAddInventorySugarBiggerThanZero() {
		int amtCoffee = -3;
		int amtMilk = 2;
		int amtSugar = 1;
		int amtChocolate = 2;
		Assert.assertFalse(cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate));
	}
	
	@Test
	public void testCheckInventory() {

	}

	@Test
	public void testMakeCoffee() {
		cm.addRecipe(r1);
		int expected = 2;
		Assert.assertEquals(expected, cm.makeCoffee(r1, 5));
	}

	@Test
	public void testMakeCoffeeNoEnoughIngr() {
		r2.setAmtChocolate(17);
		r2.setAmtCoffee(20);
		r2.setAmtMilk(19);
		r2.setAmtSugar(19);
		r2.setName("tea");
		r2.setPrice(3);
		cm.addRecipe(r2);
		int expected = 5;
		Assert.assertEquals(expected, cm.makeCoffee(r2, 5));
	}
	
	@Test
	public void testMakeCoffeeCanNot() {
		cm.addRecipe(r1);
		int expected = 2;
		Assert.assertEquals(expected, cm.makeCoffee(r1, 2));
	}
	
	@Test
	public void testGetRecipes() {
	}

	@Test
	public void testGetRecipeForName() {
		cm.addRecipe(r1);
		Assert.assertSame(r1,cm.getRecipeForName("Nervana") );
	}
	

}
